﻿using System;
using System.Runtime.Serialization;

namespace YWM.Entities
{
    //
    // 摘要:
    //     This exception is thrown if an entity excepted to be found but not found.
    [Serializable]
    public class EntityNotFoundException : Exception
    {
        //
        // 摘要:
        //     Type of the entity.
        public Type EntityType { get; set; }

        //
        // 摘要:
        //     Id of the Entity.
        public object Id { get; set; }

        //
        // 摘要:
        //     Creates a new Abp.Domain.Entities.EntityNotFoundException object.
        public EntityNotFoundException()
        {
        }

        //
        // 摘要:
        //     Creates a new Abp.Domain.Entities.EntityNotFoundException object.
        public EntityNotFoundException(SerializationInfo serializationInfo, StreamingContext context)
            : base(serializationInfo, context)
        {
        }

        //
        // 摘要:
        //     Creates a new Abp.Domain.Entities.EntityNotFoundException object.
        public EntityNotFoundException(Type entityType, object id)
            : this(entityType, id, null)
        {
        }

        //
        // 摘要:
        //     Creates a new Abp.Domain.Entities.EntityNotFoundException object.
        public EntityNotFoundException(Type entityType, object id, Exception innerException)
            : base($"There is no such an entity. Entity type: {entityType.FullName}, id: {id}", innerException)
        {
            EntityType = entityType;
            Id = id;
        }

        //
        // 摘要:
        //     Creates a new Abp.Domain.Entities.EntityNotFoundException object.
        //
        // 参数:
        //   message:
        //     Exception message
        public EntityNotFoundException(string message)
            : base(message)
        {
        }

        //
        // 摘要:
        //     Creates a new Abp.Domain.Entities.EntityNotFoundException object.
        //
        // 参数:
        //   message:
        //     Exception message
        //
        //   innerException:
        //     Inner exception
        public EntityNotFoundException(string message, Exception innerException)
            : base(message, innerException)
        {
        }
    }
}
